package com.shanghaionstar.nav.adapter;

import android.content.Context;
import android.widget.TextView;

import com.onstar.cn.framework.annotation.FindViewById;
import com.onstar.cn.framework.base.CommonAdapter;
import com.onstar.cn.framework.base.CommonViewHolder;
import com.onstar.cn.weight.CustomImageView;
import com.shanghaionstar.R;

import java.util.List;
import java.util.Map;

public class NavSearchItemGridViewAdapter extends CommonAdapter<Map<String, Object>> {

    private List<Map<String, Object>> items;
    private Context context;

    public NavSearchItemGridViewAdapter(List<Map<String, Object>> datas, Context context) {
        super(datas, context);
        this.items = datas;
        this.context = context;
    }

    @Override
    public void getView(int position, CommonViewHolder viewHolder) {
        ViewHolder holder = (ViewHolder) viewHolder;
        holder.grid_image.setImageResource((Integer) items.get(position).get("grid_image"));
        holder.text_item_info.setText(items.get(position).get("text_item_info").toString());
//        if (DeviceUtil.getLanguage().equalsIgnoreCase("en")) {
//            holder.text_item_info.setTextSize(10);
//        } else {
//            holder.text_item_info.setTextSize(14);
//        }
        holder.text_item_info.setTextSize(14);
    }

    @Override
    public CommonViewHolder getViewHolder() {
        return new ViewHolder();
    }

    @Override
    public int layoutId() {
        return R.layout.nav_search_item_grid_item;
    }

    private class ViewHolder extends CommonViewHolder {
        @FindViewById(R.id.grid_image)
        CustomImageView grid_image;
        @FindViewById(R.id.text_item_info)
        TextView text_item_info;
    }
}
